--威武领军
local weiwulingjun = fk.CreateSkill {
    name = "mcdh_weiwulingjun"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

weiwulingjun:addEffect('active',{
    can_use = function(self, player)
        return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
    end,
    card_filter = Util.FalseFunc,
    target_filter = function (self, player,to_select, selected)
        return to_select ~= player
    end,
    min_target_num = 1,
    on_use = function (self, room, use)
        room:sortByAction(use.tos)
        local player = use.from
        local targets = {}
        for _, t in ipairs(use.tos) do
            if #t:getCardIds(Player.Hand) <= #player:getCardIds(Player.Hand)  then
                 table.insert(targets,t)
            end
        end
        for _, t in ipairs(targets) do
           if not t.dead then
                t:drawCards(1,self.name)
           end
        end
        targets = {}
        for _, t in ipairs(use.tos) do
            if #t:getCardIds(Player.Hand) > #player:getCardIds(Player.Hand)  then
                table.insert(targets,t)
            end
        end

        for _, t in ipairs(targets) do
                local target = t
                local c = room:askForCard(target,1,1,true,self.name,false,".","#mcdh_weiwulingjun_askcard")
                room:moveCards({
                    ids = c,
                    from = target,
                    toArea = Card.DrawPile,
                    moveReason = fk.ReasonPut,
                    skillName = self.name,
                    proposer = target,
                })
        end
    end
})

Fk:loadTranslationTable{
    ["mcdh_weiwulingjun"] = "领军",
    [":mcdh_weiwulingjun"] = "『威武领军』<br>出牌阶段限一次，你可以选择任意名其他角色，其中手牌数小于等于你的角色各摸一张牌，然后其中手牌数大于你的角色各将一张牌置于牌堆顶。",
}
return weiwulingjun